<?php
function getDb($connect = true)
{
	global $database;
    static $db = null;
    
	if(function_exists('mysqli_connect')){
		require_once('mysql/mysqli.class.php');
	}
	elseif (function_exists('mysql_connect')){
		require_once('mysql/mysql.class.php');
	}
	else{
		die("No extention for mysql or mysqli!");
	}
    if (null == $db){
	    $db =  new DbMySQL(
            $database['host'], 
            $database['user'], 
            $database['pwd'], 
            $database['db'],
            $database['port']);
	    $db->debug = $database['debug'];
	    $db->printErrMsg = $database['print_error_sql'];
    }
	if ($connect) {
		$db->connect();
	}
	return $db;
}
